package com.android.sama;
import BLL.*;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

public class Login extends Activity {

	
	TextView userNameTxt,passwordTxt;
	Button loginBtn;
	CheckBox saveChkbox;
	Common Common=new Common();
	Intent in;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		final AlertDialog builder = new AlertDialog.Builder(this).create();
		
		userNameTxt =(TextView)findViewById(R.id.userNameTxt);
		passwordTxt=(TextView)findViewById(R.id.passwordTxt);
		saveChkbox=(CheckBox)findViewById(R.id.saveChkBox);
		loginBtn=(Button)findViewById(R.id.loginBtn);
		loginBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(Common.CheckLogin(userNameTxt.getText().toString(), 
						passwordTxt.getText().toString())==true)
				{
					in=new Intent(getApplicationContext(),MainActivity.class);
					startActivity(in);
				}
				else
				{
					builder.setMessage("Username and password incorrect!");
					builder.show();
				}//
			}
		});

	}

	
}
